package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVO;
import com.itheima.health.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
public interface UserMapper extends BaseMapper<User> {
    @Select("select * from t_user where username=#{username}")
    UserVO findUserByUsername(@Param("username") String username);

    @Select("select r.* from t_role r,t_user_role ur where r.id=ur.role_id and ur.user_id=#{uid}")
    List<RoleVO> findRolesByUid(@Param("uid") Integer uid);

    @Select("select p.* from t_permission p,t_role_permission rp where p.id=rp.permission_id and rp.role_id=#{rid}")
    List<Permission> findPermssionsByRoleId(@Param("rid") Integer rid);
}
